package com.wg.model;

import xyz.erupt.annotation.Erupt;
import xyz.erupt.annotation.EruptField;
import xyz.erupt.annotation.sub_erupt.Power;
import xyz.erupt.annotation.sub_field.Edit;
import xyz.erupt.annotation.sub_field.EditType;
import xyz.erupt.annotation.sub_field.View;
import xyz.erupt.annotation.sub_field.sub_edit.ChoiceType;
import xyz.erupt.annotation.sub_field.sub_edit.VL;
import xyz.erupt.jpa.model.BaseModel;
import xyz.erupt.toolkit.handler.SqlChoiceFetchHandler;

import javax.persistence.*;

@Erupt(name = "wginfo", power = @Power(
        importable = true, export = true
))
@Table(name = "tb_wginfos")
@Entity
public class WgInfoModel extends BaseModel {
    @EruptField(
            views = @View(title = "WG名称"),
            edit = @Edit(title = "WG名称")
    )
    private String name;

    @EruptField(
            views = @View(title = "WG日程"),
            edit = @Edit(title = "WG日程")
    )
    private String schedule;

    @EruptField(
            views = @View(title = "WG描述"),
            edit = @Edit(title = "WG描述", type = EditType.TEXTAREA)
    )
    private String description;

    @EruptField(
            views = @View(title = "创建者"),
            edit = @Edit(
                    title = "创建者",
                    type = EditType.CHOICE,
                    choiceType = @ChoiceType(
                            fetchHandler = SqlChoiceFetchHandler.class,
                            fetchHandlerParams = {"select id, name from tb_users", "5000"}
                    )
            )
    )
    private Long creatorId;

    @EruptField(
            views = @View(title = "WG目录"),
            edit = @Edit(title = "WG目录")
    )
    private String learnoutcome;


    @EruptField(
            edit = @Edit(title = "选择器", type = EditType.CHOICE,
                    choiceType = @ChoiceType(
                            vl = {
                                    @VL(label = "未完成", value = "0"),
                                    @VL(label = "已完成", value = "1")
                            }
                    ))
    )
    private Integer status;

    @EruptField(
            views = @View(title = "年份"),
            edit = @Edit(title = "年份")
    )
    private String year;


}
